import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:test/locale/chinese_cupertino_localizations.dart';
import 'package:test/locale/english_cupertino_localizations.dart';

class GlobalCupertinoLocalizationsDelegate extends LocalizationsDelegate<CupertinoLocalizations> {

  const GlobalCupertinoLocalizationsDelegate();

  @override
  bool isSupported(Locale locale) => ['zh', 'en'].contains(locale.languageCode);

  @override
  Future<CupertinoLocalizations> load(Locale locale) async {
    if (locale.languageCode == 'en') {
      return EnglishCupertinoLocalizations();
    } else if (locale.languageCode == 'zh') {
      return ChineseCupertinoLocalizations();
    }
    return EnglishCupertinoLocalizations();
  }

  @override
  bool shouldReload(LocalizationsDelegate<CupertinoLocalizations> old) {
    return false;
  }
}